package {{.ModuleName}}

import (
    "context"
    {{- $bb := false -}}
    {{- range .Columns -}}
    {{- $z := .IsQuery -}}
    {{- if ($z) -}}
    {{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
    {{- end -}}
    {{- end -}}
    {{- range .Columns -}}
    {{- if eq .GoField "CreatedAt" -}}
    {{- else if eq .GoField "UpdatedAt" -}}
    {{- else if eq .GoField "DeletedAt" -}}
    {{- else -}}
    {{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
    {{- end -}}
    {{- end -}}
    {{- if eq $bb true }}
    "time"
    {{- end }}

	"go-caipu/pkg/services/dto"
)

type Get{{.ClassName}}PageCommand struct {
	dto.Pagination     `search:"-"`
    {{- $tablename := .TBName -}}
    {{- range .Columns -}}
    {{$z := .IsQuery}}
    {{- if ($z) }}
    {{.GoField}} {{.GoType}} `form:"{{.JsonField}}"  search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}" comment:"{{.ColumnComment}}"`
    {{- end }}
    {{- end }}
}

type {{.ClassName}} struct{
    {{ range .Columns -}}
    {{- if eq .GoField "CreatedAt" -}}
    {{- else if eq .GoField "UpdatedAt" -}}
    {{- else if eq .GoField "DeletedAt" -}}
    {{- else if eq .GoField "CreateBy" -}}
    {{- else if eq .GoField "UpdateBy" -}}
    {{- else }}
    {{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
    {{- end }}
    dto.ControlBy
    dto.ModelTime
}

func (m *Get{{.ClassName}}PageCommand) GetNeedSearch() interface{} {
	return *m
}
type Get{{.ClassName}}Command struct {
	{{.PkGoField}} int64 `uri:"id"`
}

type Remove{{.ClassName}}Command struct {
	Ids []int64 `json:"ids"`
}


//Service 业务接口
type Service interface {
	Get{{.ClassName}}Page(ctx context.Context, cmd Get{{.ClassName}}PageCommand) (data []{{.ClassName}}, num int64, err error)
	Get(ctx context.Context, cmd Get{{.ClassName}}Command) ({{.ClassName}}, error)
	Insert(ctx context.Context, cmd {{.ClassName}}) error
	Update(ctx context.Context, cmd {{.ClassName}}) error
	Remove(ctx context.Context, cmd Remove{{.ClassName}}Command) error
}



